import http, { BASE_URL } from "@/utils/http";
import utils from "@/utils/utils";
// 规则查询
export const getRules = (params) => {
  return http.get("/pub/user/rules", params);
};
//上传
export const upload = (data) => {
  return new Promise((resolve, reject) => {
    uni.uploadFile({
      url: BASE_URL + "/auth/common/upload",
      filePath: data,
      name: "file",
      header: {
        Authorization: uni.getStorageSync("token"),
      },
      success: (res) => {
        if (res.statusCode == 200) {
          const { url, code } = JSON.parse(res.data);
          if (code == 200) {
            resolve(url);
          } else {
            reject();
          }
        } else {
          reject();
        }
      },
      fail: (err) => {
        reject(err.errMsg);
      },
    });
  });
};
